package com.yequan.socket.mutilthread;

import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author : Administrator
 * @date : 2020/2/14
 */
public class Server {

    public static void main(String[] args) {
        try {
            //1.创建一个服务器端socket
            ServerSocket serverSocket = new ServerSocket(8888);
            System.out.println("*********服务器已启动*********");
            int count = 0;
            while (true) {
                Socket socket = serverSocket.accept();
                ServerThread serverThread = new ServerThread(socket);
                serverThread.start();
                count++;
                System.out.println("客户端数量: " + count);
                InetAddress inetAddress = socket.getInetAddress();
                System.out.println("当前客户端IP: " + inetAddress.getHostAddress());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
